home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / mui32dev.lha / MUI / Developer / Modula / Demo / MuiTest.mod < prev   
Text File  |  1995-11-18  |  7KB  |  206 lines

  1. MODULE MuiTest;
  2.  
  3. (*$ LargeVars:=FALSE *)
  4.  
  5. (*
  6. ** This is just a little demo Prg. to show how to use MUI in Modula
  7. ** It has no functions, it just looks good (who cares.... ;-)
  8. ** Please note : There was a little bugfix in this version.
  9. **               Look where the WindowID gets defined - you have
  10. **               to write MakeID("....") instead of ADR("....")
  11. **               then MUI will store your window position!!
  12. **
  13. ** Version : 13.10.1993
  14. *)
  15.  
  16. IMPORT MD:MuiD;
  17. IMPORT ML:MuiL;
  18. IMPORT MM:MuiMacros;
  19. FROM   MuiMacros IMPORT set,get,MakeID;
  20. FROM   MuiSupport IMPORT DOMethod, DoMethod, APTR, fail;
  21. FROM   SYSTEM IMPORT TAG, ADR, LONGSET, CAST;
  22. FROM   ExecL IMPORT Wait;
  23. FROM   UtilityD IMPORT tagEnd;
  24.  
  25. TYPE
  26.     ShortString = ARRAY[0..3] OF CHAR;
  27.  
  28. CONST
  29.     True  = 1;      (* These are for the set-Macro *)
  30.     False = 0;      (* because set excepts just LONGINT as argument *)
  31.     
  32.     IDbut1= 1;      (* The IDs for the Buttons *)
  33.     IDbut2= 2;
  34.     IDbut3= 3;
  35.     IDbut4= 4;
  36.     IDbut5= 5;
  37.     IDbut6= 6;
  38.  
  39. VAR app,window,bt1,bt2,bt3,bt4,bt5,bt6,Dirs  : APTR;
  40.     signals                                  : LONGSET;
  41.     running                                  : BOOLEAN;
  42.     msg                                      : LONGINT;
  43.     buffer                                   : ARRAY[0..30] OF LONGINT;
  44.     buffer1                                  : ARRAY[0..30] OF LONGINT;
  45.     buffer2                                  : ARRAY[0..30] OF LONGINT;
  46.     buffer3                                  : ARRAY[0..30] OF LONGINT;
  47.  
  48. BEGIN
  49.  
  50.     running := TRUE;
  51.  
  52.     (* Set up the buttons *)
  53.  
  54.     bt1 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Button 1"), tagEnd));
  55.     bt2 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("B_utton 2"), tagEnd));
  56.     bt3 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Bu_tton 3"), tagEnd));
  57.     bt4 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Butt_on 4"), tagEnd));
  58.     bt5 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Butto_n 5"), tagEnd));
  59.     bt6 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("_Cancel"), tagEnd));
  60.  
  61.     (* Set up the Volumelist *)
  62.  
  63.     Dirs:= MM.ListviewObject(TAG(buffer1,
  64.                 MD.maListviewList,  MM.VolumelistObject(TAG(buffer2,
  65.                                         MD.maFrame,         MD.mvFrameInputList,
  66.                                         MD.maFrameTitle,    ADR("Magic Volumes"),
  67.                                         tagEnd)),
  68.                 tagEnd));
  69.  
  70.     (* Set up the window *)
  71.  
  72.     window := MM.WindowObject(TAG(buffer,
  73.                     MD.maWindowTitle   , ADR("MUI-Test :-)"),
  74.                     MD.maWindowID      , MakeID("MAIN"),
  75.  
  76.                     MM.WindowContents,
  77.  
  78.                         (* Create an array of Buttons *)
  79.  
  80.                         MM.VGroup(TAG(buffer3,
  81.                             MM.Child, MM.HGroup(TAG(buffer1,
  82.                                     MD.maFrame,         MD.mvFrameGroup,
  83.                                     MD.maFrameTitle,    ADR("Magic Buttons"),
  84.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  85.                                             MM.Child, bt1,
  86.                                             MM.Child, bt2,
  87.                                             MM.Child, bt3,
  88.                                             tagEnd)),
  89.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  90.                                             MM.Child, bt4,
  91.                                             MM.Child, bt5,
  92.                                             MM.Child, bt6, (* cancel *)
  93.                                             tagEnd)),
  94.                                     tagEnd)),
  95.  
  96.                             (* Put the Volumelist below them *)
  97.  
  98.                             MM.Child, Dirs,
  99.                             tagEnd)),
  100.                 tagEnd));
  101.  
  102.     (* set up the application object *)
  103.  
  104.     app:=MM.ApplicationObject(TAG(buffer,
  105.                     MD.maApplicationTitle      , ADR("MUITest"),
  106.                     MD.maApplicationVersion    , ADR("V1.0ß"),
  107.                     MD.maApplicationCopyright  , ADR("©1993 by Christian Scholz"),
  108.                     MD.maApplicationAuthor     , ADR("Tochkopf"),
  109.                     MD.maApplicationDescription, ADR("Test the MUI-Magic :-)"),
  110.                     MD.maApplicationBase       , ADR("MUITest"),
  111.  
  112.                     MM.SubWindow, window,
  113.  
  114.             tagEnd));
  115.  
  116.     IF app=NIL THEN fail(app, "failed to create Application !!"); END;
  117.  
  118. (* Set up the notification *)
  119.  
  120.             DoMethod(window,TAG(buffer,
  121.                         MD.mmNotify,MD.maWindowCloseRequest,TRUE,
  122.                         app,2,MD.mmApplicationReturnID,IDbut6
  123.                         ));
  124.  
  125.             DoMethod(bt1,TAG(buffer,
  126.                         MD.mmNotify,MD.maPressed,FALSE,
  127.                         app,2,MD.mmApplicationReturnID,IDbut1
  128.                         ));
  129.  
  130.             DoMethod(bt2,TAG(buffer,
  131.                         MD.mmNotify,MD.maPressed,FALSE,
  132.                         app,2,MD.mmApplicationReturnID,IDbut2
  133.                         ));
  134.  
  135.             DoMethod(bt3,TAG(buffer,
  136.                         MD.mmNotify,MD.maPressed,FALSE,
  137.                         app,2,MD.mmApplicationReturnID,IDbut3
  138.                         ));
  139.  
  140.             DoMethod(bt4,TAG(buffer,
  141.                         MD.mmNotify,MD.maPressed,FALSE,
  142.                         app,2,MD.mmApplicationReturnID,IDbut4
  143.                         ));
  144.  
  145.             DoMethod(bt5,TAG(buffer,
  146.                         MD.mmNotify,MD.maPressed,FALSE,
  147.                         app,2,MD.mmApplicationReturnID,IDbut5
  148.                         ));
  149.  
  150.             DoMethod(bt6,TAG(buffer,
  151.                         MD.mmNotify,MD.maPressed,FALSE,
  152.                         app,2,MD.mmApplicationReturnID,IDbut6
  153.                         ));
  154.  
  155. (* Cycle Chain for Keyboard *)
  156.  
  157.             DoMethod(window,TAG(buffer,
  158.                         MD.mmWindowSetCycleChain,
  159.                         bt1, bt2, bt3, bt4, bt5, bt6, Dirs, 0
  160.                         ));
  161.  
  162. (* Main Loop *)
  163.  
  164.             (* Open the window and set first active object
  165.                Here is also shown, how to use True and False in set *)
  166.  
  167.             set(window,MD.maWindowOpen, True);
  168.             set(window,MD.maWindowActiveObject, Dirs);
  169.  
  170.             (* Event Loop *)
  171.  
  172.             WHILE running DO
  173.  
  174.                         CASE DOMethod(app, TAG(buffer,
  175.                                MD.mmApplicationInput, ADR(signals))) OF
  176.  
  177.                         |   MD.mvApplicationReturnIDQuit, IDbut6:
  178.                                     running:=FALSE;
  179.                         |   IDbut1,IDbut2,IDbut3,IDbut4, IDbut5:
  180.                                     fail(app, "Application failed of no reason");
  181.                         ELSE
  182.  
  183.                         END;
  184.  
  185.  
  186.                         IF running AND (signals <> LONGSET{} ) THEN signals:=Wait(signals);
  187.                                                    END;
  188.             END; (* While *)
  189.  
  190.             (* Close window *)
  191.  
  192.             set(window,MD.maWindowOpen, False);
  193.  
  194. (* Shut up *)
  195.  
  196.         fail(app,"");
  197.  
  198. END MuiTest.
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.